/*
============================================================================
 Name        : KeyWatcher.h
 Author      : DANG Zhengfa
 Version     :
 Copyright   : Zhengfa Company Limited
 Description : CKeyWatcher declaration
============================================================================
*/

#ifndef KEYWATCHER_H
#define KEYWATCHER_H

#include <e32base.h>	// For CActive, link against: euser.lib
#include <e32std.h>		// For RTimer, link against: euser.lib

#include <w32std.h>      // For RWsSession,CWsScreenDevice,RWindowGroup, ws32.lib 
#include <apgwgnam.h>    // For CApaWindowGroupName, apgrfx.lib

class CKeyLocker;
class CScreenCapture;
class CAudioRecorder;

class CKeyWatcher : public CActive
{
public:
	// C++ constructor
	CKeyWatcher();
	
	// Second-phase constructor
	void ConstructL();
	
	// Cancel and destroy
	~CKeyWatcher();

public: // New functions
	// Function for making the initial request
	void StartL();
	// Pass CKeyLocker ptr to watcher
	void SetKeyLocker(CKeyLocker* aLocker);
	// pass screen catpure ptr to watcher
	void SetScreenCapture(CScreenCapture* aCapture);


private: // From CActive
	// Handle completion
	void RunL();
	
	// How to cancel me
	void DoCancel();
	
	// Override to handle leaves from RunL(). Default implementation causes
	// the active scheduler to panic.
	TInt RunError(TInt aError);

private:
	void CaptureKeyL(void);
	TBool CaptureScreenL(void);
	TBool StartStopRecordL(void);

private:
	RWsSession iWS;
	RWindowGroup iWG;
	CWsScreenDevice *iScreen;
	CApaWindowGroupName *iWN;
	
	// ptr to keylocker
	CKeyLocker* iLocker;
	CScreenCapture* iCapture;

	// handles to key capture
	TInt32 iHotkeyStar;
	TInt32 iHotkeyCross;
	TInt32 iHotkeyZero;

	// ptr to audio recorder
	CAudioRecorder *iRecorder;

};

#endif
